package com.zhangh.summer.admin.support.ds.redis;

import redis.clients.jedis.*;
import redis.clients.util.Pool;
import redis.clients.util.Slowlog;

import java.util.List;
import java.util.Map;
import java.util.Set;

public interface IRedisClient {

	/**
	 * 获取Jedis
	 * @return
	 */
	public Jedis getResource();

	/**
	 * 设置值
	 * @param key
	 * @param value
	 * @param seconds 超时时间，0表示不过期
	 * @return
	 */
	public String set(String key, String value, int seconds);

	/**
	 * 设置值
	 * @param key
	 * @param value 值，可以是java对象，自动转成json存储。
	 * @param seconds 超时时间，0表示不过期
	 * @return
	 */
    public String set(String key, Object value, int seconds);

	/**
	 * 获取值
	 * @param key
	 * @param clazz 对象class
	 * @param <T>
	 * @return
	 */
    public <T> T get(String key, Class<T> clazz);

	/**
	 * 获取string值
	 * @param key
	 * @return
	 */
	public String get(String key);

	/**
	 * 获取集合值
	 * @param key
	 * @param collectionClazz 集合class
	 * @param objClazz 集合对象 class
	 * @param <T>
	 * @param <M>
	 * @return
	 */
	public <T,M> T get(String key, Class<T> collectionClazz, Class<M> objClazz);



	public String set(String key, String value);

	public String set(String key, String value, String nxxx, String expx, long time);

	public Boolean exists(String key);

	public Long del(String... keys);

	public Long del(String key) ;

	public String type(String key);

	public Set<String> keys(String pattern);

	public String randomKey() ;

	public String rename(String oldkey, String newkey);

	public Long renamenx(String oldkey, String newkey) ;

	public Long expire(String key, int seconds);

	public Long expireAt(String key, long unixTime);

	public Long ttl(String key);

	public Long move(String key, int dbIndex);

	public String getSet(String key, String value);

	public List<String> mget(String... keys);

	public Long setnx(String key, String value);

	public String setex(String key, int seconds, String value);

	public String mset(String... keysvalues);

	public Long msetnx(String... keysvalues);

	public Long decrBy(String key, long integer);

	public Long decr(String key);

	public Long incrBy(String key, long integer);

	public Double incrByFloat(String key, double value);

	public Long incr(String key) ;

	public Long append(String key, String value);

	public String substr(String key, int start, int end);

	public Long hset(String key, String field, String value);

	public String hget(String key, String field) ;

	public Long hsetnx(String key, String field, String value);

	public String hmset(String key, Map<String, String> hash);

	public String hmset(byte[] key, Map<byte[], byte[]> hash);

	public List<String> hmget(String key, String... fields);

	public Long hincrBy(String key, String field, long value);

	public Double hincrByFloat(String key, String field, double value);

	public Boolean hexists(String key, String field) ;

	public Long hdel(String key, String... fields) ;

	public Long hlen(String key);

	public Set<String> hkeys(String key);

	public List<String> hvals(String key);

	public Map<String, String> hgetAll(String key);

	public Map<byte[], byte[]> hgetAll(byte[] key);

	public Long rpush(String key, String... strings);

	public Long lpush(String key, String... strings);

	public Long llen(String key);

	public List<String> lrange(String key, long start, long end);

	public String ltrim(String key, long start, long end);

	public String lindex(String key, long index);

	public String lset(String key, long index, String value);

	public Long lrem(String key, long count, String value);

	public String lpop(String key);

	public String rpop(String key) ;

	public String rpoplpush(String srckey, String dstkey);

	public Long sadd(String key, String... members);

	public Set<String> smembers(String key) ;

	public Long srem(String key, String... members);

	public String spop(String key);

	public Long smove(String srckey, String dstkey, String member) ;

	public Long scard(String key);

	public Boolean sismember(String key, String member) ;
	public Set<String> sinter(String... keys) ;

	public Long sinterstore(String dstkey, String... keys) ;

	public Set<String> sunion(String... keys) ;

	public Long sunionstore(String dstkey, String... keys) ;

	public Set<String> sdiff(String... keys) ;

	public Long sdiffstore(String dstkey, String... keys) ;

	public String srandmember(String key);

	public List<String> srandmember(String key, int count) ;

	public Long zadd(String key, double score, String member);

	public Long zadd(String key, Map<String, Double> scoreMembers);

	public Set<String> zrange(String key, long start, long end);

	public Long zrem(String key, String... members);
	public Double zincrby(String key, double score, String member);

	public Long zrank(String key, String member) ;

	public Long zrevrank(String key, String member);

	public Set<String> zrevrange(String key, long start, long end);

	public Set<Tuple> zrangeWithScores(String key, long start, long end) ;

	public Set<Tuple> zrevrangeWithScores(String key, long start, long end) ;

	public Long zcard(String key);

	public Double zscore(String key, String member);

	public String watch(String... keys);

	public List<String> sort(String key);

	public List<String> sort(String key, SortingParams sortingParameters);

	public List<String> blpop(int timeout, String... keys) ;

	public List<String> blpop(String... args);

	public List<String> brpop(String... args) ;

	public List<String> blpop(String arg) ;

	public List<String> brpop(String arg) ;

	public Long sort(String key, SortingParams sortingParameters, String dstkey);
	public Long sort(String key, String dstkey) ;

	public List<String> brpop(int timeout, String... keys) ;

	public Long zcount(String key, double min, double max) ;
	public Long zcount(String key, String min, String max);

	public Set<String> zrangeByScore(String key, double min, double max) ;

	public Set<String> zrangeByScore(String key, String min, String max) ;

	public Set<String> zrangeByScore(String key, double min, double max, int offset, int count);

	public Set<String> zrangeByScore(String key, String min, String max, int offset, int count) ;

	public Set<Tuple> zrangeByScoreWithScores(String key, double min, double max) ;

	public Set<Tuple> zrangeByScoreWithScores(String key, String min, String max) ;

	public Set<Tuple> zrangeByScoreWithScores(String key, double min, double max, int offset, int count);

	public Set<Tuple> zrangeByScoreWithScores(String key, String min, String max, int offset, int count);


	public Set<String> zrevrangeByScore(String key, double max, double min) ;

	public Set<String> zrevrangeByScore(String key, String max, String min);
	public Set<String> zrevrangeByScore(String key, double max, double min, int offset, int count) ;

	public Set<Tuple> zrevrangeByScoreWithScores(String key, double max, double min);

	public Set<Tuple> zrevrangeByScoreWithScores(String key, double max, double min, int offset, int count) ;

	public Set<Tuple> zrevrangeByScoreWithScores(String key, String max, String min, int offset, int count) ;

	public Set<String> zrevrangeByScore(String key, String max, String min, int offset, int count);

	public Set<Tuple> zrevrangeByScoreWithScores(String key, String max, String min) ;

	public Long zremrangeByRank(String key, long start, long end);

	public Long zremrangeByScore(String key, double start, double end) ;

	public Long zremrangeByScore(String key, String start, String end);

	public Long zunionstore(String dstkey, String... sets) ;

	public Long zunionstore(String dstkey, ZParams params, String... sets);

	public Long zinterstore(String dstkey, String... sets);

	public Long zinterstore(String dstkey, ZParams params, String... sets);

	public Long strlen(String key) ;

	public Long lpushx(String key, String... string);

	public Long persist(String key);

	public Long rpushx(String key, String... string);

	public String echo(String string);

	public Long linsert(String key, BinaryClient.LIST_POSITION where, String pivot, String value);

	public String brpoplpush(String source, String destination, int timeout);

	public Boolean setbit(String key, long offset, boolean value) ;

	public Boolean setbit(String key, long offset, String value) ;

	public Boolean getbit(String key, long offset) ;

	public Long setrange(String key, long offset, String value) ;
	public String getrange(String key, long startOffset, long endOffset);

	public Long bitpos(String key, boolean value) ;

	public Long bitpos(String key, boolean value, BitPosParams params) ;

	public List<String> configGet(String pattern) ;

	public String configSet(String parameter, String value) ;

	public Object eval(String script, int keyCount, String... params) ;

	public void subscribe(JedisPubSub jedisPubSub, String... channels);

	public Long publish(String channel, String message);

	public void psubscribe(JedisPubSub jedisPubSub, String... patterns);

	public Object eval(String script, List<String> keys, List<String> args) ;
	public Object eval(String script);

	public Object evalsha(String script);

	public Object evalsha(String sha1, List<String> keys, List<String> args);

	public Object evalsha(String sha1, int keyCount, String... params) ;

	public Boolean scriptExists(String sha1) ;

	public List<Boolean> scriptExists(String... sha1) ;

	public String scriptLoad(String script) ;

	public List<Slowlog> slowlogGet() ;

	public List<Slowlog> slowlogGet(long entries) ;

	public Long objectRefcount(String string) ;

	public String objectEncoding(String string) ;

	public Long objectIdletime(String string);

	public Long bitcount(String key) ;

	public Long bitcount(String key, long start, long end) ;

	public Long bitop(BitOP op, String destKey, String... srcKeys) ;

	public List<Map<String, String>> sentinelMasters() ;

	public List<String> sentinelGetMasterAddrByName(String masterName);

	public Long sentinelReset(String pattern);

	public List<Map<String, String>> sentinelSlaves(String masterName);

	public String sentinelFailover(String masterName);

	public String sentinelMonitor(String masterName, String ip, int port, int quorum) ;

	public String sentinelRemove(String masterName) ;

	public String sentinelSet(String masterName, Map<String, String> parameterMap) ;

	public byte[] dump(String key) ;

	public String restore(String key, int ttl, byte[] serializedValue) ;

	/** @deprecated */
	@Deprecated
	public Long pexpire(String key, int milliseconds) ;

	public Long pexpire(String key, long milliseconds);

	public Long pexpireAt(String key, long millisecondsTimestamp) ;

	public Long pttl(String key) ;

	public String psetex(String key, int milliseconds, String value);

	public String set(String key, String value, String nxxx) ;

	public String set(String key, String value, String nxxx, String expx, int time) ;

	public String clientKill(String client) ;

	public String clientSetname(String name);

	public String migrate(String host, int port, String key, int destinationDb, int timeout) ;

	/** @deprecated */
	@Deprecated
	public ScanResult<String> scan(int cursor);

	/** @deprecated */
	@Deprecated
	public ScanResult<String> scan(int cursor, ScanParams params);

	/** @deprecated */
	@Deprecated
	public ScanResult<Map.Entry<String, String>> hscan(String key, int cursor) ;

	/** @deprecated */
	@Deprecated
	public ScanResult<Map.Entry<String, String>> hscan(String key, int cursor, ScanParams params) ;

	/** @deprecated */
	@Deprecated
	public ScanResult<String> sscan(String key, int cursor) ;

	/** @deprecated */
	@Deprecated
	public ScanResult<String> sscan(String key, int cursor, ScanParams params);

	/** @deprecated */
	@Deprecated
	public ScanResult<Tuple> zscan(String key, int cursor);

	/** @deprecated */
	@Deprecated
	public ScanResult<Tuple> zscan(String key, int cursor, ScanParams params) ;

	public ScanResult<String> scan(String cursor);

	public ScanResult<String> scan(String cursor, ScanParams params) ;

	public ScanResult<Map.Entry<String, String>> hscan(String key, String cursor) ;

	public ScanResult<Map.Entry<String, String>> hscan(String key, String cursor, ScanParams params) ;

	public ScanResult<String> sscan(String key, String cursor) ;

	public ScanResult<String> sscan(String key, String cursor, ScanParams params) ;

	public ScanResult<Tuple> zscan(String key, String cursor);

	public ScanResult<Tuple> zscan(String key, String cursor, ScanParams params);

	public String clusterNodes() ;

	public String clusterMeet(String ip, int port);
	public String clusterAddSlots(int... slots);

	public String clusterDelSlots(int... slots) ;

	public String clusterInfo() ;

	public List<String> clusterGetKeysInSlot(int slot, int count);

	public String clusterSetSlotNode(int slot, String nodeId);
	public String clusterSetSlotMigrating(int slot, String nodeId) ;

	public String clusterSetSlotImporting(int slot, String nodeId);

	public String clusterSetSlotStable(int slot);

	public String clusterForget(String nodeId);

	public String clusterFlushSlots();
	public Long clusterKeySlot(String key);

	public Long clusterCountKeysInSlot(int slot);

	public String clusterSaveConfig() ;

	public String clusterReplicate(String nodeId);

	public List<String> clusterSlaves(String nodeId);

	public String clusterFailover();

	public String asking();
	public List<String> pubsubChannels(String pattern);

	public Long pubsubNumPat() ;

	public Map<String, String> pubsubNumSub(String... channels);


	public void setDataSource(Pool<Jedis> jedisPool);

	public Long pfadd(String key, String... elements);

	public long pfcount(String key) ;

	public long pfcount(String... keys) ;

	public String pfmerge(String destkey, String... sourcekeys);

}
